import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete
} from '@nestjs/common'
import { MenuService } from './menu.service'
import { CreateMenuDto } from './dto/create-menu.dto'
import { UpdateMenuDto } from './dto/update-menu.dto'
import { NoAuth } from 'src/role/decorators/no-auth.decorator'
import { ApiBody, ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger'
@NoAuth()
@ApiTags('菜单')
@Controller('menu')
export class MenuController {
  constructor(private readonly menuService: MenuService) {}

  @Post()
  @ApiOperation({ summary: '创建菜单' })
  @ApiBody({ type: CreateMenuDto, description: '菜单信息' })
  create(@Body() createMenuDto: CreateMenuDto) {
    return this.menuService.create(createMenuDto)
  }

  @Get()
  @ApiOperation({ summary: '获取所有菜单' })
  findAll() {
    return this.menuService.findAll()
  }

  @Get(':id')
  @ApiOperation({ summary: '获取单个菜单' })
  @ApiParam({ name: 'id', description: '菜单id' })
  findOne(@Param('id') id: string) {
    return this.menuService.findOne(+id)
  }

  @Patch(':id')
  @ApiOperation({ summary: '更新菜单' })
  @ApiParam({ name: 'id', description: '菜单id' })
  @ApiBody({ type: UpdateMenuDto, description: '菜单信息' })
  update(@Param('id') id: string, @Body() updateMenuDto: UpdateMenuDto) {
    return this.menuService.update(+id, updateMenuDto)
  }

  @Delete(':id')
  @ApiOperation({ summary: '删除菜单' })
  @ApiParam({ name: 'id', description: '菜单id' })
  remove(@Param('id') id: string) {
    return this.menuService.remove(+id)
  }
  @Patch('restore/:id')
  @ApiOperation({ summary: '恢复菜单' })
  @ApiParam({ name: 'id', description: '菜单id' })
  restore(@Param('id') id: string) {
    return this.menuService.restore(+id)
  }
}
